<?php
/**
 * 登录日志
 */
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLoginLogTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('login_log', function (Blueprint $table) {
            $table->increments('id');
            $table->tinyInteger('type')->default(1)->comment('用户类型 1:平台 2:用户');
            $table->integer('user_id')->comment('用户id type=1 关联admin_user表id type=2 关联users表id');
            $table->string('ip',20)->comment('最后登录ip');
            $table->timestamp('time')->comment('最后登录时间');
            $table->tinyInteger('platform')->default(0)->comment('1:pc 2:手机端');
            $table->string('client_id')->comment('客户端id');
            $table->timestamp('out_time')->nullable()->comment('退出时间');
            $table->integer('length_time')->default(0)->comment('登录时长');
//            $table->timestamps();
//            $table->softDeletes();
        });
        //添加表注释
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `".config('database.connections.mysql.prefix')."login_log` comment'用户登录日志'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('login_log');
    }
}
